﻿using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

namespace CKS2320.Domain.DBEntity
{
    public partial class DBContext : DbContext
    {
        public DBContext()
        {
        }

        public DBContext(DbContextOptions<DBContext> options)
            : base(options)
        {
        }

        public virtual DbSet<Datastatus> Datastatuses { get; set; } = null!;
        public virtual DbSet<Detectiondetail> Detectiondetails { get; set; } = null!;
        public virtual DbSet<Equipmentfailure> Equipmentfailures { get; set; } = null!;
        public virtual DbSet<Equipmentfailurehistory> Equipmentfailurehistories { get; set; } = null!;
        public virtual DbSet<Indicatortolerancezone> IndicatorToleranceZones { get; set; } = null!;
        public virtual DbSet<Keyencedatadetail> Keyencedatadetails { get; set; } = null!;
        public virtual DbSet<Shape> Shapes { get; set; } = null!;
        public virtual DbSet<Thicknessdetection> Thicknessdetections { get; set; } = null!;
        public virtual DbSet<Voltagewithstand> Voltagewithstands { get; set; } = null!;
        public virtual DbSet<PerformanceRecord> PerformanceRecords { get; set; } = null!;

        public virtual DbSet<Op10coredata> Op10coreDatas { get; set; } = null!;
        public virtual DbSet<Op20coredata> Op20coreDatas { get; set; } = null!;
        public virtual DbSet<Op30coredata> Op30coreDatas { get; set; } = null!;
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
                optionsBuilder.UseSqlServer("Server=.\\SQLEXPRESS;Database=CKS2320;Trusted_Connection=True;");
                // optionsBuilder.UseSqlServer("Server=.\\;Database=CKS2320;Trusted_Connection=True;");
            }
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<Datastatus>(entity =>
            {
                entity.Property(e => e.Id).ValueGeneratedNever();
            });

            modelBuilder.Entity<Detectiondetail>(entity =>
            {
                entity.Property(e => e.Id).ValueGeneratedNever();
            });

            modelBuilder.Entity<Equipmentfailure>(entity =>
            {
                entity.Property(e => e.Id).ValueGeneratedNever();
            });

            modelBuilder.Entity<Equipmentfailurehistory>(entity =>
            {
                entity.Property(e => e.Id).ValueGeneratedNever();
            });

            modelBuilder.Entity<Indicatortolerancezone>(entity =>
            {
                entity.Property(e => e.Id).ValueGeneratedNever();
            });

            modelBuilder.Entity<Keyencedatadetail>(entity =>
            {
                entity.Property(e => e.Id).ValueGeneratedNever();
            });

            modelBuilder.Entity<Shape>(entity =>
            {
                entity.Property(e => e.Id).ValueGeneratedNever();
            });

            modelBuilder.Entity<Thicknessdetection>(entity =>
            {
                entity.Property(e => e.Id).ValueGeneratedNever();
            });

            modelBuilder.Entity<Voltagewithstand>(entity =>
            {
                entity.Property(e => e.Id).ValueGeneratedNever();
            });

            OnModelCreatingPartial(modelBuilder);
        }

        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
    }
}
